package com.neu.wangweili.servlet;

import com.neu.wangweili.service.W_ClassService;
import com.neu.wangweili.service.W_DeptService;
import com.neu.wangweili.service.W_DorService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "W_LeftToAddStuServlet", urlPatterns = {"/W_LeftToAddStuServlet"})
public class W_LeftToAddStuServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("UTF-8");
        W_DeptService w_deptService=new W_DeptService();
        List<Map<String,Object>>list=w_deptService.findAll();
        W_DorService w_dorService=new W_DorService();
        List<Map<String,Object>>build=w_dorService.findAllBuild();
        System.out.println(list.size());
        System.out.println("build"+build.size());
        if(list.size()>0 && build.size()>0){
            HttpSession session=request.getSession();
            session.setAttribute("item",list);
            session.setAttribute("build",build);
            request.getRequestDispatcher("WEB-INF/Mgr/addstu.jsp").forward(request,response);
        }else {
            request.getRequestDispatcher("commons/fail.jsp").forward(request,response);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
